package sk.isomi.minihr.mssql;

import java.sql.DriverManager;
import java.sql.SQLException;

public class SQLReader_jDTS extends SQLReader {
	public static final String urlPrefix = "jdbc:jtds:sqlserver://";

	public SQLReader_jDTS(String server, int port, String instanceName, String database, String user, String password) {
		super(server, port, instanceName, database, user, password);
	}
	
	public boolean connect() {
		boolean success = false;

		String urlSQL = String.format("%s%s:%d/%s;instance=%s", urlPrefix, server, port, database, instanceName);
		
		try {
			 Class.forName("net.sourceforge.jtds.jdbc.Driver");
			conSQL = DriverManager.getConnection(urlSQL, user, password);
			success = true;
		} catch (ClassNotFoundException e) {
			conSQL = null;
			e.printStackTrace();
		} catch (SQLException e) {
			conSQL = null;
			e.printStackTrace();
		}

		return success;
	}

}
